min max python

28

def clamp(n, minn, maxn):
    return max(min(maxn, n), minn)
def min_max(*n):
  return {"min":min(n),"max":max(n)}
print(min_max(-10,1,2,3,45))
listA = [18, 19, 21, 22]
print('The smallest number from listA is:', min(listA))  	# 18
print('The largest number from listA is:', max(listA))		# 22

strA = 'AppDividend'
print('The smallest character from strA is:', min(strA))	# A
print('The largest character from strA is:', max(strA))		# v

strA = 'AppDividend'
strB = 'Facebook'
strC = 'Amazon'
print('The smallest string is:', min(strA, strB, strC))		# Amazon
print('The largest string is:', max(strA, strB, strC))		# Facebook
>>> max(7,22,733,56)
733
>>> min(3,3663,8727,82)
3
>>> max('hello', 'how', 'are', 'you')
'you'
>>> min('hello', 'how', 'are', 'you', 'Sir')
'Sir'

Comments

Submit
0 Comments